//
//  AddressViewController.m
//  SDHuiYuShoping
//
//  Created by luojiao on 2017/6/12.
//  Copyright © 2017年 luojiao. All rights reserved.
//

#import "AddressViewController.h"
#import "AddressTCell.h"
#import "AddadressVC.h"
#import "UIViewController+KNSemiModal.h"//third

@interface AddressViewController ()
{
    NSArray *nameArr;
}

@end

@implementation AddressViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    nameArr = [[NSArray alloc] initWithObjects:@"收货人：",@"联系方式：",@"所在地区：", nil];
    self.tableview.separatorStyle = NO;
    //设置返回按钮
    [self.backButton setImage:[UIImage imageNamed:@"back_white_btn"] forState:UIControlStateNormal];
    [self.backButton setImageEdgeInsets:UIEdgeInsetsMake(0, -50, 0, 0)];
    [self.backButton setTitle:@"返回" forState:UIControlStateNormal];
    [self.backButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -40, 0, 0)];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)backButton:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}



#pragma mark - tableViewdelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AddressTCell *cell;
    
    static NSString *cellIdentifier = @"addressTCell";
    cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell)
    {
        cell = [[NSBundle mainBundle] loadNibNamed:@"AddressTCell" owner:self options:nil][0];
    }
    //cell 没有选中状态
    cell.address.text = [nameArr objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [cell.addressChose addTarget:self action:@selector(cellButtonClink) forControlEvents:UIControlEventTouchUpInside];
    [cell.addressChose setImage:[UIImage imageNamed:@"unfold_btn"] forState:UIControlStateNormal];
    [cell.addressChose setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, -APP_WIDTH)];
    if (indexPath.row == 2)
    {
        cell.addressChose.hidden = NO;
    }
    else
    {
        cell.addressChose.hidden = YES;
    }
    return cell;
}


-(void)cellButtonClink
{
    
    //用于推出选择地址页面
    AddadressVC *addadressVC = [[AddadressVC alloc] init];
    addadressVC.view.frame = CGRectMake(0, APP_HEIGHT - 350, APP_WIDTH, 350);
//    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:addressViewController];
//    nav.view.frame = CGRectMake(0, self.view.frame.size.height - 400, self.view.frame.size.width, 400);
    
    [self.navigationController presentSemiViewController:addadressVC withOptions:@{KNSemiModalOptionKeys.pushParentBack    : @(NO),KNSemiModalOptionKeys.animationDuration : @(0.6),KNSemiModalOptionKeys.shadowOpacity     : @(0.8)}];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
